<?php
    $args = array(
        'post_type' => 'store',
        'post_status' => 'publish',
        'posts_per_page' => -1,
        'meta_query' => array(
            array(
                'key' => 'url_store_metadata',
                'value' => $_GET['term'],
                'compare' => 'LIKE'
            )
        )
    );
    $query = new WP_Query($args);
    $store = $query->posts;
    $suggestions=array();
    foreach ($store as $st){
        $url = get_post_meta($st->ID,'url_store_metadata',true);
        $_url = explode('.', $url);
        $pos = strpos($url,'www');
        if($pos !== false){
            $_url = explode('w.', $url);
            $url_simple = $_url[1];
        }else{
            $_url = explode('/', $url);
            $url_simple = $_url[2];
        }
        $suggestion['post_title'] = $url_simple;  
        array_push($suggestions, $suggestion['post_title']);
    }
    $response = json_encode($suggestions);  
    echo $response;
    die();
?>
